home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / dosevrn.dqc / dos-evrn.doc
Text File  |  1985-07-14  |  4KB  |  102 lines

  1. From rss Fri Jun 21 19:33 CDT 1985
  2.  
  3.  
  4. How to fix the environment space in DOS.
  5.  
  6. By Roger Schlafly, Borland International
  7.  
  8.  
  9. Memory allocation for environment space was badly botched by
  10. Microsoft. DOS only allocates 127 bytes initially, and this
  11. cannot be increased after loading a resident program like PRINT
  12. or Sidekick. DOS will allocate more memory if no program is
  13. resident and the set command was typed at the keyboard, but
  14. running set commands from batch files is totally unreliable.
  15.  
  16. The following patch increases the environment space to 2K on
  17. PC-DOS 3.1:
  18.  
  19.         debug COMMAND.COM
  20.         e cs:D11
  21.         80
  22.         w
  23.         q
  24.  
  25.  
  26. How the patch works.
  27.  
  28. At boot time, COMMAND.COM allocates memory for the environment
  29. space by DOS function call 48H. The argument for this function is
  30. the number of paragraphs to be allocated, and is in register BX.
  31. A paragraph is 16 bytes. COMMAND.COM allocates 160 bytes when it
  32. creates the environment space, so it calls DOS function 48H with
  33. 0AH in register BX. In earlier versions of DOS, including PC-DOS
  34. 2.00, the code in COMMAND.COM which set the environment space
  35. was:
  36.  
  37.         MOV     BX,0AH
  38.         MOV     AH,48H
  39.         INT     21H
  40.  
  41. These versions of DOS can be patched by searching COMMAND.COM for
  42. these instructions:
  43.  
  44.         debug COMMAND.COM
  45.         s cs:0 6000 BB 0A 00 B4 48 CD 21
  46.  
  47. There should be just one occurrence. Changing the 0A to 80 (hex)
  48. will increase the environment space to about 2K the next time you
  49. reboot.
  50.  
  51. Later versions of DOS, including PC-DOS 3.10, store the number of
  52. paragraphs to allocate to the environment in a memory location in
  53. the data segment. The relevant code is:
  54.  
  55.         cs:0D0D C7063A138000   MOV    Word Ptr [133A],000A
  56.  
  57.         cs:0FFF 8B1E3A13       MOV    BX,[133A]
  58.         cs:1003 B448           MOV    AH,48
  59.         cs:1005 CD21           INT    21
  60.  
  61. Note that the memory location [133A] is valid for PC-DOS 3.10
  62. only. If you have another version of DOS, or a non-IBM version of
  63. MS-DOS 3.10, the memory location may be different. The following
  64. procedure may be used to find the correct byte to patch.
  65.  
  66. 1. Load COMMAND.COM into DEBUG. (Preferably, not your only copy.)
  67.  
  68. 2. Search for all 48H DOS functions by searching for the hex
  69. string B4 48 CD 21. There are about ten.
  70.  
  71. 3. Unassemble the surrounding code to see what gets loaded into
  72. BX. If BX is being set to FFFFH or any constant other than 0AH,
  73. or is based on a computation, then you are looking at the wrong
  74. function call.
  75.  
  76. 4. There should be just one function call left. If 0AH is being
  77. copied directly into BX, then that is the byte to patch. If a
  78. memory location is being copied into BX, then search for moves
  79. into that memory location. For example, if the memory location is
  80. 1234, then search for C7 06 34 12 0A 00 since those are the
  81. opcodes for MOV Word Ptr [1234],000AH. This 0AH can be replaced
  82. by a larger number.
  83.  
  84.  
  85. Final remarks.
  86.  
  87. 1. Needless to say, modifying the wrong byte in COMMAND.COM can
  88. have undesirable consequences. If you are not sure that you
  89. patched it correctly and you notice DOS acting peculiarly,
  90. restore the old copy of COMMAND.COM.
  91.  
  92. 2. A company called Soft Shell Technology used to sell a very
  93. nice program which could expand the environment space and fix a
  94. number of other botches such as the inability of Wordstar to run
  95. from other than the default directory. Sadly, however, they went
  96. out of business and their program only worked with PC-DOS 2.00.
  97.  
  98. 3. According to Soft Shell Technology, the number to replace 0AH
  99. in COMMAND.COM should not be between 2DH and 45H.
  100.  
  101.  
  102.